# ADDR 
# adjusting pvalues to account for the FWER
# when construcing Table A13 we export unadjuasted pvalues in the output folder
library(tidyverse)
library(stats)
library(data.table)

# path to unadjusted pavalues
dt = ".../replication/output/unadj_pv_sp146_FLS_NT13NT19.csv" %>% fread() %>% 
  group_by(spec, sample) %>% 
  mutate(holm_pv = p.adjust(standard_pv, method = "holm", n = 4)) %>% 
  mutate(bonf_pv = p.adjust(standard_pv, method = "bonferroni", n = 4)) %>%
  mutate(hoch_pv = p.adjust(standard_pv, method = "hochberg", n = 4)) %>%
  mutate(hommel_pv = p.adjust(standard_pv, method = "hommel", n = 4)) %>% 
  mutate_at(vars(ends_with("pv")), ~round(., 2)) %>% 
  arrange(sample, depvar, spec)


dt %>% 
  # path to adjusted pvalues
  fwrite(., ".../replication/output/adj_pv_sp146_allsamples.csv")
